The Controller Area Network (CAN) protocol is a serial communication protocol for communicating between various electronic devices of a vehicle such as an automobile. In accordance with the CAN protocol, multiple different electronic devices of a vehicle can be coupled to a single serial bus such that messages and data may be sent from one electronic device of the vehicle to another. The CAN protocol is a message based protocol in which CAN frames are placed on a common CAN bus. The CAN bus may be a single wire or may be a differentially driven pair of wires. Each electronic device ("node") on the common CAN bus receives each frame present on the bus and filters out those frames which are not required in performing that node's tasks. For example, if a device associated with an automobile dashboard sends onto the CAN bus a frame requesting that the automobile headlights be turned on, then the device on the CAN bus responsible for the brake lights can determine that the frame is intended for another node and therefore will not act upon the frame. The device controlling the headlights, however, receives and acts upon the frame by turning the headlights on. Identifier bits are therefore provided in CAN frames to allow messages and data to be directed to certain nodes on the CAN bus and not to other nodes on the CAN bus.
FIGS. 1A-D (Prior Art) are diagrams illustrating four different types of CAN frames. In FIGS. 1A-D, an "r" designates a bit having recessive logic level and a "d" designates a bit having a dominant logic level. If one node places a dominant bit on the bus at the same time that another node places a recessive bit on the bus, the bus will assume the logic level of the dominant bit. By monitoring the voltage level on the bus, the node attempting to transmit the recessive bit is able to determine that the bus is not idle but rather that traffic exists on the bus. Additionally, between each frame is a 3-bit intermission field, each bit of which is `recessive`.
FIG. 1A is a diagram of a CAN data frame. Data frames are used to transmit information such as data and/or messages from one node to another node over the CAN bus. The data frame of FIG. 1A includes a start of frame bit, a 12-bit arbitration field, a 6-bit control field, a data field, a 16-bit cyclic redundancy check (CRC) field, a 2-bit acknowledgement field and a 7-bit end of frame field. The arbitration field includes an 11-bit identifier and a remote transmission request (RTR) bit, which, for a data frame, is `dominant`. The data field includes up to eight bytes of data. A message may, for example be encoded in the date field.
FIG. 1B is a diagram of a CAN remote frame. A remote frame is used to request data from other CAN nodes. A remote frame is identical to a data frame except that the remote transmission request (RTR) bit of the arbitration field is `recessive` and there is no data field.
FIG. 1C is a diagram of a CAN error frame. Error frames are used to communicate error conditions detected on the CAN bus to other nodes. An error frame can start anywhere in the middle of another frame. Nodes that signal an error frame do so by either sending six recessive bits or six dominant bits. Nodes that receive the error frame distinguish it by receiving data that does not obey the rules of "bit stuffing". So after six error bits, the receiving node signals that it has seen an error and begins sending its own error frame. Consequently, there can be 12 dominant bits on the CAN bus, six bits of which come from the sender of the error flag and six bits of which come from the receiver of the error flag.
FIG. 1D is a diagram of a CAN overload frame. An overload frame is used to indicate that a receiving node is not able to process all the information sent to it over the CAN bus. An overload frame can only start at the end of another frame. Nodes that wish to slow the flow of information on the CAN bus do so by sending an "overload frame" at the end of a data frame. The overload frame is similar to an error frame bus since an overload frame can only be initiated at the end of a message, receiving nodes can distinguish the overload frame from an error frame and leave their fault confinement logic untouched. Receiving nodes see the start of an overload frame immediately since "bit stuffing" does not apply at the end of the message and therefore there may be up to seven bits in an overload frame.
Using these four types of frames, information can be passed back and forth between the various devices (nodes) coupled to a CAN bus.
The CAN protocol provides for fault confinement in which CAN nodes are able to distinguish short disturbances from permanent failures. Defective nodes are switched to a busoff state. During the busoff state, no messages can be transmitted by the node. During the busoff state, messages can be monitored by the node for correctness, i.e., for whether a message is error free; however, the content of the message is ignored. A node which is in the busoff state is permitted to switch to an error active state when certain conditions are met.
A node enters the error active state, in which the node's error counters are both set to zero, after 128 occurrences of eleven consecutive recessive bits having been monitored on the bus. A node also enters the error active state at power-on or reset. The eleven consecutive recessive bits are provided by the 1-bit acknowledge delimiter field, the 7-bit end of frame field and the 3-bit intermission field or by recessive bits that are present when the bus is in idle state. The 11 recessive bits starting from the acknowledge delimiter can only be decoded if a message has been correctly decoded including the cyclic redundancy check without error.
Recessive bits are automatic when the bus is in the idle state; i.e., when the bus is not being used, the state of the bus is recessive and appears to all receivers as a succession of recessive bits which receivers count in groups of 11 bits. Accordingly, when the bus is in an idle state, 128*11 recessive bits are provided by the total of all the intermessage spaces. That is all of the time between messages are added up to form the total quiet time. When the total quiet time exceeds 128*11 bit times, the device can leave the busoff state. Ten or less recessive bits during the idle time between messages does not count towards the total quite time. Under the fault confinement portion of the CAN protocol, a node waits for 128 groups of 11 recessive bits regardless of where they are relative to messages appearing on the network. Thus, a bus which is in the idle state provides any node which is in the busoff state with a time out condition that switches the node back to the error active state.
FIG. 2 is an illustration of a typical electronic device coupled to a CAN bus in a vehicle. The device includes a core processor 1, an associated CAN interface 2, and input/output circuitry 3. The input/output circuitry 3 couples the core processor to the vehicle. The input/output circuitry 3 may, for example, be coupled to actuators and sensors which are part of a control loop. The input/output circuitry 3 may include input/output circuitry such as drivers, amplifiers, buffers, registers, timers, A/D converters, and D/A converters disposed on a single integrated circuit chip with the processor core. The input/output circuitry may also include input/output circuitry not realized on the same integrated circuit as the processor core. The CAN interface 2 couples the core processor 1 to a CAN bus 4.
In one CAN interface of the prior art, communication transactions are handled by the CAN interface. In order to transmit a message, the core processor places the data field of a frame to be transmitted into a transmit buffer of the CAN interface 2 which is adequately long to hold the data field. The core processor 1 than sets a designated bit in the CAN interface which indicates to the CAN interface that a frame containing the information in the transmit buffer is to be transmitted. The CPU is then free to attend to other tasks while the CAN interface transmits the frame. The CAN interface determines that the bus is idle and then transmits the frame, the bits of the data field being sent from the transmit buffer in the CAN interface. Similarly, when a frame is to be received, the CAN interface receives the entire data field of the frame into a single receive buffer in the CAN interface which is adequately long to hold the received data field. Only if the frame was received error free does the CAN interface alert the core processor. If any transmission error occurs, the CAN interface handles the error in accordance with the CAN protocol without requiring any action by the core processor. The core processor is therefore able to read the complete correctly received data field from the receive buffer of the CAN interface.
In one known system which implements the CAN fault confinement protocol, when a node detects that a reset request signal has been set, the node aborts the current transmission or reception of a message and enters a reset state. The reset request signal may be generated either by an external reset or by a central processing unit within the core processor. The CAN interface controller starts normal operation in one of two ways upon detecting the reset request signal. If the reset request signal was generated by an external reset, then the CAN interface controller starts normal operation after the first occurrence of eleven recessive bits. Alternately, the CAN interface controller starts normal operation after the first occurrence of eleven recessive bits if the reset request is cleared by the central processing unit unless bus status (BS) is already set. If the BS signal is set, which indicates that the device is not participating in bus activities (i.e., that the node is in the busoff state), then the CAN interface controller waits for the 128th occurrence of eleven recessive bits before starting normal operation.
In another system, a software initialization procedure is started by setting an initialization bit in a control register either by software reset, hardware reset or by going busoff. While the initialization bit is set, all message transfers to and from the node are stopped and the transmit outputs are recessive. The error counters are unchanged. Initialization is used to configure the node without risk of CAN bus receptions or transmissions. Resetting the initialization bit completes initialization and the node synchronizes itself to the CAN bus by waiting for eleven consecutive recessive bits before the node will take part in bus activities. Busoff recovery cannot be hastened by setting or resetting the initialization bit. If the node goes busoff, the node sets the initialization bit itself and thereby stops its bus activities. Once the initialization bit is cleared by the central processing unit, the node waits for 128 occurrences of eleven consecutive recessive bits, before resuming normal operation. During the initialization sequence, each time a recessive bit is received, an error code is written to the status register enabling the CPU to readily check whether or not the CAN bus is stuck in a dominant state.